angular.module('shop-manage', ['pop-up'])

.controller 'ShopManageCtrl', ($scope, $state,$http,popUpSrv,mallInfo,userData,$ionicPopup,$ionicHistory,showToast) ->
    $http.get('/seller/', params: {action: 'showshop', userid: userData.getToken()})
    .success (resp) ->
        if resp?.status == '0'
            mallInfo.mall = resp
            if mallInfo.mall.logo == ''
                mallInfo.mall.logo='img/img-picker/img-add.png'
            if mallInfo.mall.bannerimg == ''
                mallInfo.mall.bannerimg='img/img-picker/img-add.png'
        else
            showToast resp.error
    .error ->
        showToast '您的网络又调皮了'
    _.extend $scope,
        goBack: ->
            $ionicHistory.goBack()
        goMallInfo: ->
            if $state.is('tab.shop-manage-home')
                $state.go 'tab.mall-info-home'
            else if $state.is('tab.shop-manage-myself')
                $state.go 'tab.mall-info-myself'
        uploadlogo: ->
            if $state.is('tab.shop-manage-home')
                $state.go 'tab.mall-logo-home'
            else if $state.is('tab.shop-manage-myself')
                $state.go 'tab.mall-logo-myself'
        gobanner: ->
            if $state.is('tab.shop-manage-home')
                $state.go 'tab.mall-banner-home'
            else if $state.is('tab.shop-manage-myself')
                $state.go 'tab.mall-banner-myself'
        goContact: ->
            if $state.is('tab.shop-manage-home')
                $state.go 'tab.contact-home'
            else if $state.is('tab.shop-manage-myself')
                $state.go 'tab.contact-myself'
        goWithdrawCash:->
            $state.go 'tab.withdraw-cash'
        goTranDetail:->
            $state.go 'tab.transaction-detail'
        goInvoice:->
            $state.go 'tab.invoice-apply'